home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Automation / Scripts / Effect - Zoom Exit.js < prev    next >
Encoding:
Text File  |  2002-05-13  |  4.3 KB  |  137 lines

  1. /***************************************************************
  2. ADOBE SYSTEMS INCORPORATED 
  3. Copyright 2002 Adobe Systems Incorporated 
  4. All Rights Reserved 
  5.  
  6. NOTICE:  Adobe permits you to use, modify, and distribute this 
  7. file in accordance with the terms of the Adobe license agreement 
  8. accompanying it.  If you have received this file from a source 
  9. other than Adobe, then your use, modification, or distribution
  10. of it requires the prior written permission of Adobe. 
  11. ***************************************************************/
  12. /***************************************************************
  13. Author: Mary Obelnicki
  14. ***************************************************************/
  15.  
  16. /***************************************************************
  17.  
  18. The following script creates a key frame animation effect on 
  19. the currently selected objects.
  20.  
  21. Function:
  22.     zoomexit(letters, frames, stagger, opacity, rotation, xdiff, ydiff, zdiff, forward, startNow, KFR)
  23.  
  24. Arguments:
  25.     <letters> LMObject - an array of the objects to apply the 
  26.         effect. Does not have to be text objects.  It can be 
  27.         any LMObject.
  28.     <frames> integer - the length of the animation for each 
  29.         object
  30.     <stagger> integer - the number of frames to stagger the 
  31.         start of each animation
  32.     <opacity> integer - the opacity to end at
  33.     <rotation> integer - the rotation to end at
  34.     <xdiff>, <ydiff>, <zdiff> integer - the x,y,z difference 
  35.         from the initial position to end at.  In 3-d space.
  36.     <forward> boolean - stagger from first character or 
  37.         last character
  38.     <KFR> integer - the number of frames between key frames.
  39.  
  40. ***************************************************************/
  41.  
  42. #include "../../Include/Camera.js"
  43.  
  44. /***************************************************************
  45. To change the behavior of this script, make your changes below
  46. ***************************************************************/
  47.  
  48. var objects = application.currentComposition.selection; 
  49. zoomexit(objects, 12, 0, 0, 0, 0, 0, -800, false, true, 2); 
  50.  
  51. /***************************************************************
  52. DO NOT EDIT BELOW THIS LINE
  53. ***************************************************************/
  54.  
  55. function zoomexit(letters, frames, stagger, opacity, rotation, xdiff, ydiff, zdiff, forward, startNow, KFR)
  56. {
  57.     if(letters.length < 1)
  58.     return; 
  59.     keyFrameRate = KFR; 
  60.     
  61.     //create the camera
  62.     var midIndex = Math.ceil((letters.length)/2) -1;
  63.     var xe = letters[midIndex].position.x; 
  64.     var ye = letters[midIndex].position.y; 
  65.     var camera = new Camera(new Vector(xe, ye, -1000)); 
  66.  
  67.     var frame0;
  68.     if (startNow)
  69.      frame0 = letters[0].currentFrame;
  70.     else
  71.     frame0 = letters[0].currentFrame - (stagger * (letters.length - 1) + frames);      
  72.     
  73.     var dxdf = xdiff/frames; 
  74.     var dydf = ydiff/frames; 
  75.     var dzdf = zdiff/frames;
  76.     
  77.     for (i=0; i < letters.length; i++)
  78.     {
  79.     var cl;
  80.     if (forward)
  81.         cl = letters[i];
  82.     else
  83.         cl = letters[letters.length -1 -i];
  84.     var xo = cl.position.x; 
  85.     var yo = cl.position.y;
  86.     var zo = 0; 
  87.     var oriOpacity = cl.opacity; 
  88.     var oriRotation = cl.rotation;
  89.     
  90.     //turn on relevant stopwatches    
  91.     
  92.     if (opacity != oriOpacity)
  93.         cl.stopwatch.opacity = true;     
  94.     if (rotation != oriRotation) 
  95.         cl.stopwatch.rotation = true; 
  96.     
  97.     //I'm going to turn on the relevant stopwatches myself
  98.     camera.perspectiveSetup(cl, false);
  99.     
  100.     if (zdiff == 0)
  101.     {// test xdiff and ydiff
  102.         if((xdiff != 0) || (ydiff != 0))
  103.         cl.stopwatch.position = true; 
  104.     }
  105.     
  106.     else
  107.     {
  108.         cl.stopwatch.position = true; //should this be in perspectivesetup?
  109.         cl.stopwatch.scale = true; // this too?    
  110.     }
  111.  
  112.     //first frame
  113.     cl.currentFrame = frame0 + (i * stagger);
  114.     camera.perspectiveTransform(cl, new Vector(xo, yo, zo));
  115.     cl.opacity = oriOpacity;
  116.     cl.rotation = oriRotation; 
  117.     
  118.     if (zdiff != 0)
  119.     {
  120.         //middle frames
  121.         for(df =0; df < frames; df+=keyFrameRate)
  122.         {
  123.         cl.currentFrame = frame0 + df + (i * stagger); 
  124.         camera.perspectiveTransform(cl, new Vector(xo+(dxdf*df), yo+(dydf * df), zo+(dzdf * df))); 
  125.         }
  126.     }    
  127.     
  128.     //last frame    
  129.     
  130.     cl.currentFrame = frame0 + frames + (i * stagger);
  131.     camera.perspectiveTransform(cl, new Vector(xo+xdiff, yo+ydiff, zo+zdiff));
  132.     cl.opacity = opacity;
  133.     cl.rotation = rotation;
  134.     }
  135. }
  136.  
  137.